package com.qunar.forex.exchange.model;

import com.google.gson.annotations.SerializedName;
import com.qunar.forex.exchange.util.GsonUtil;
import org.apache.commons.lang3.builder.*;

import java.io.Serializable;

/**
 * Created by stgan on 2016/9/24.
 */
public class BaseEntity implements Serializable {
    private static final long serialVersionUID = 1L;
    @SerializedName("Result")
    private Result result;
    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
    }

    @Override
    public int hashCode() {
        return HashCodeBuilder.reflectionHashCode(this);
    }

    public int compareTo(Object obj){
        return CompareToBuilder.reflectionCompare(this, obj);
    }

    @Override
    public boolean equals(Object obj) {
        return EqualsBuilder.reflectionEquals(this, obj);
    }

    public String toJson(){
        return GsonUtil.toJson(this);
    }

    public static <T> T getBean(String json, Class<T> cls){
        return GsonUtil.getBean(json, cls);
    }

    public Result getResult() {
        return result;
    }

    public void setResult(Result result) {
        this.result = result;
    }
}
